define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");

	var Model = function(){
		this.callParent();
	};

	Model.prototype.backBtnClick = function(event){
		this.comp("windowReceiver1").windowEnsure();
		this.getParentModel().goBackHome();

	};



	


	Model.prototype.onTouchStart = function(event){
		$(event.currentTarget).addClass("touch");

	};



	Model.prototype.onTouchEnd = function(event){
		$(event.currentTarget).removeClass("touch");
	};



	Model.prototype.modelLoad = function(event){
		
		
//		console.log('ok');
//		var areaName = this.getParentModel().getCompanyName();
//		
//		var userName = this.getParentModel().getUserName();
//		
//		this.comp("area").val(areaName);
//		
//		this.comp("name").val(userName);
		

	};


    //保存
	Model.prototype.saveBtnClick = function(event){
		var url = "http://www.xjzlhy.com:81/ex_community/a/api/community/repairs?callback=?";
		var me = this;
		var companyId = this.getParentModel().getCompanyId();
		$.getJSON(url,
				{
					"office.id":companyId,
					"name":me.comp("name").val(),
					"trouble":me.comp("trouble").val(),
					"phone":me.comp("phone").val(),
					"mobile":me.comp("mobile").val(),
					"address":me.comp("address").val()
				
				},
				
				function(data,status){
				   
					justep.Util.hint("保存成功",{type:"success"});
					me.reset();
				}
				
		);
		
	};
	
	Model.prototype.reset = function(event){
		this.comp("trouble").val('');
		this.comp("phone").val('');
		this.comp("mobile").val('');
		this.comp("address").val('');
	};



	Model.prototype.windowReceiver1Receive = function(event){
		console.log('ok');
		var areaName = this.getParentModel().getCompanyName();
		
		var userName = this.getParentModel().getUserName();
		
		this.comp("area").val(areaName);
		
		this.comp("name").val(userName);
	};



	return Model;
});